package cn.edu.ujn.zzylab2.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.zzylab2.dao.User;
import cn.edu.ujn.zzylab2.dao.UserMapper;
@Service("userService")
@Transactional
public class UserServiceImpl implements IUserService {
    @Autowired
	private UserMapper userDao;
	
	@Override
	public int addUser(User user) {
		
		return userDao.insert(user);
	}

	@Override
	public int deleteUser(int id) {
		int delete = this.userDao.deleteByPrimaryKey(id);
		return delete;
	}

	@Override
	public User updateUser(User user) {
		int update = this.userDao.updateByPrimaryKey(user);
		return user;
	}

	@Override
	public User findById(int id) {
		
		return this.userDao.selectByPrimaryKey(id);
	}

	@Override
	public List<User> findAll() {
		
		return this.userDao.findAll();
	}

}
